//
//  BHCommonChoseAddressViewController.swift
//  BigHealth
//
//  Created by 蔺百好 on 2021/6/25.
//  选择地址页面

import UIKit

class BHCommonChoseAddressViewController: BHBaseViewController {

    
    lazy var headerSearchView: BHChoseAddressSearchView = {
        let view = BHChoseAddressSearchView.loadFromXib()
        view.frame = CGRect(x: 0, y: UIScreen.begainY, width: UIScreen.width, height: 54)
        return view
    }()
    
    
    lazy var bottomView: BHChoseAddressBottomView = {
        let view = BHChoseAddressBottomView.loadFromXib()
        view.frame = CGRect(x: 0, y: UIScreen.height-BHChoseAddressBottomView.height, width: UIScreen.width, height: BHChoseAddressBottomView.height)
        return view
    }()
    
    
    lazy var tableView: UITableView = {
        let view = UITableView.buildTableView(style: .plain)
        view.frame = CGRect(x: 0, y: UIScreen.begainY+54, width: UIScreen.width, height: UIScreen.showHeight-54)
        view.delegate = self
        view.dataSource = self
        view.isHidden = true
        view.regiseterNib(nibName: "BHSearchAddressTableViewCell")
        return view
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()

        self.bh_navigationBar.title_label.text = "自定义地址"
        
        self.view.backgroundColor = .color_f8f8f8
        
        self.view.addSubview(self.headerSearchView)
        self.view.addSubview(self.bottomView)
        self.view.addSubview(self.tableView)
       
        self.headerSearchView.begainSearchEdite = { [weak self] in
            self?.tableView.isHidden = false
        }
    }
    


}


extension BHCommonChoseAddressViewController: UITableViewDataSource {
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 10
    }
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
       return 77
    }
    
}

extension BHCommonChoseAddressViewController: UITableViewDelegate {
 
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "BHSearchAddressTableViewCell", for: indexPath) as! BHSearchAddressTableViewCell
   
        return cell
    }
}
